package com.cloud.pole.user.biz.authorized;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ace.cache.annotation.Cache;
import com.cloud.pole.common.biz.BaseBiz;
import com.cloud.pole.mapper.authorized.UserAuthorizedWxMapper;
import com.cloud.pole.user.model.entity.authorized.UserAuthorizedWx;

/**
 * ${DESCRIPTION}
 *
 * @author wanghaobin
 * @create 2017-06-08 16:23
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserAuthorizedWxBiz extends BaseBiz<UserAuthorizedWxMapper, UserAuthorizedWx> {
	
    @Cache(key="userAuthorizedWx{1}")
    public UserAuthorizedWx selectByOpenId(String openId) {
    	UserAuthorizedWx entity = new UserAuthorizedWx();
    	entity.setOpenId(openId);
        return mapper.selectOne(entity);
    }
    
    @Cache(key="userAuthorizedWx:userId{1}wxAppId{2}")
    public UserAuthorizedWx selectByUserId(Long userId, Integer wxAppId) {
    	UserAuthorizedWx entity = new UserAuthorizedWx();
    	entity.setUserId(userId);
    	entity.setWxAppId(wxAppId);
        return mapper.selectOne(entity);
    }
}
